#include<bits/stdc++.h>
using namespace std;
map<string,bool> a;
map<string,int> b;
string x,y;
int n;
int main()
{
	freopen("network.in","r",stdin);
	freopen("network.out","w",stdout);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x>>y;
		if(x=="Server"){
			if(a[y]){
				cout<<"FAIL"<<endl;
			}
			else{
				a[y]=1;
				cout<<"OK"<<endl;
				b[y]=i;
			}
		}
		else{
			if(a[y]){
				cout<<b[y]<<endl;
			}
			else cout<<"FAIL"<<endl;
		}
	}
	fclose(stdin);
	fclose(stdout);
}
